package com.shanxia.codec.enums;

import java.util.Objects;

/**
 * 系统告警
 */
public enum SystemWarningEnum {

    NO_FAULT(1, 0, "没有故障"),
    E_STOP(1, 1, "紧急停机"),
    ISOLATION_FAULT(1, 2, "绝缘故障"),
    DC_OVERVOL(1, 3, "直流过压"),
    DC_UNDERVOL(1, 4, "直流欠压"),
    SS_FAIL(1, 5, "软启失败"),
    DC_OUTPUT_INVERSE(1, 6, "直流输出反接"),
    DC_CONTACTOR_EXCEPTION(1, 7, "直流接触器异常"),
    MODULE_FAULT(2, 0, "模块故障"),
    AC_INPUT_OVERVOL(2, 1, "交流输入过压"),
    AC_INPUT_LOWVOL(2, 2, "交流输入欠压"),
    AC_INPUT_OVERFRE(2, 3, "交流输入过频"),
    AC_INPUT_LOWFRE(2, 4, "交流输入欠频"),
    MODULE_COMMU_EXCEPTION(2, 5, "模块通信异常"),
    MTYPE_NOT_SAME(2, 6, "模块类型不一致"),
    ACVOL_FALL_FAST(2, 7, "交流电压快速掉电"),
    DC_OUTPUT_CIRCURT(3, 0, "直流输出断路"),
    AIR_INTAKE_OVERTEMPE_PROTECT(3, 1, "进风口过温保护"),
    AIR_INTAKE_LOWTEMPE_PROTECT(3, 2, "进风口低温保护"),
    AIR_OUTLET_OVERTEMPE_PROTECT(3, 3, "出风口过温保护"),
    GROUP_CHARGE_OVERTEMPE(3, 4, "群充模块过温"),
    LIGHTNING_PROTECT_FAULT(3, 5, "防雷故障"),
    AC_CONTACTOR_EXCEPTION(3, 6, "交流接触器异常"),
    PILE_OVERTEMPE(3, 7, "充电枪头过温"),
    DC_OUTPUT_OVERCUR(4, 0, "直流输出过流"),
    PILE_LOCK_EXCEPTION(4, 1, "充电枪锁异常"),
    PILE_ILLEGAL(4, 2, "快充段，此枪无效"),
    ENTRANCE_GUARD_PROTECT(4, 3, "门禁保护"),
    CAN3_COMMU_ERROR(4, 4, "CAN3 通信错误"),
    GROUP_CHARGE_COMMU_FAULAT(4, 5, "群充模块通信故障"),
    INPUT_LOSE_PHASE(4, 6, "输入缺相"),
    CONTR_GUIDE_FAULT(4, 7, "控制导引故障"),
    MODULE_NOTREADY(5, 0, "模块未准备就绪"),
    V51(5, 1, "预留"),
    OPENLOCK_FAIL(5, 2, "枪锁故障 开锁失败"),
    CLOSELOCK_FAIL(5, 3, "枪锁故障 关锁失败"),
    MODULE_NOTSTART(5, 4, "软起失败，模块没有开启"),
    VOL_NOTFOUND(5, 5, "软件失败，电池电压没有检测"),
    NET_HIGHVOL_NOSHUTDOWN(5, 6, "电网电压高，告警不停机"),
    NET_LOWVOL_NOSHUTDOWN(5, 7, "电网电压低，告警不停机"),
    ISOLATION_EXCEPTION(6, 0, "绝缘异常"),
    OUTPUT_CIRCUIT(6, 1, "输出短路"),
    MODULE_OVERTEMPE(6, 2, "模块过温"),
    MODULE_EXCEPTION(6, 3, "模块异常"),
    V64(6, 4, "预留"),
    V65(6, 5, "预留"),
    V66(6, 6, "预留"),
    V67(6, 7, "预留"),
    // -------------------------------以下为国网 TCU 故障，其他客户请无视------------------------
    V70(7, 0, "绝缘异常"),
    V71(7, 1, "输出短路"),
    V72(7, 2, "模块过温"),
    TCU_E_STOP(7, 3, "模块异常"),
    SMOKE_DETECTOR_FAULT(7, 4, "烟感故障"),
    AC_INPUT_BREAKER_FAULT(7, 5, "交流输入断路器故障"),
    OUTPUT_HIGHVOL_CONTACTOR_FALSEACT_FAULT(7, 6, "输出高压接触器据动/误动故障"),
    OUTPUT_HIGHVOL_FUSE_FAULT(7, 7, "输出高压熔断器故障"),
    ELECLOCK_FAULT(8, 0, "电子锁故障"),
    FAN_FAIL(8, 1, "风扇故障"),
    LIGHTNING_PROTECTER_FAULT(8, 2, "防雷器故障"),
    ISOLATION_CHECK_FAULT(8, 3, "绝缘检测故障"),
    BATT_INVERSE(8, 4, "电池反接"),
    CHARGING_CONTR_GUIDE_FAULT(8, 5, "充电中控制导引故障"),
    CHARGER_OVERTEMPE(8, 6, "充电机过温"),
    CHARGE_INTERFACEE_OVERTEMPE(8, 7, "充电接口过温"),
    CHARGER_NOT_HOMING(9, 0, "充电器未归位"),
    COMMU_FAULT(9, 1, "通讯故障"),
    INPUT_OVERVOL(9, 2, "输入过压"),
    INPUT_LOWVOL(9, 3, "输入欠压"),
    OUTPUT_OVERVOL(9, 4, "输出过压"),
    OUTPUT_LOWVOL(9, 5, "输出欠压"),
    OUTPUT_OVERCUR(9, 6, "输出过流"),
    TCU_MODULE_FAULT(9, 7, "模块故障"),
    MODULE_AC_INPUT_FAULT(10, 0, "模块交流输入故障"),
    MODULE_AC_INPUT_OVERVOL_FAULT(10, 1, "模块交流输入过压故障"),
    MODULE_AC_INPUT_LOWVOL_FAULT(10, 2, "模块交流输入欠压故障"),
    MODULE_AC_INPUT_LOSEPHASE_FAULT(10, 3, "模块交流输入缺相故障"),
    MODULE_DC_OUTPUT_CIRCUIT(10, 4, "模块直流输出短路"),
    MODULE_DC_OUTPUT_OVERCUR(10, 5, "模块直流输出过流"),
    MODULE_DC_OUTPUT_OVERVOL(10, 6, "模块直流输出过压"),
    MODULE_DC_OUTPUT_LOWVOL(10, 7, "模块直流输出欠压"),
    CHARGE_MODULE_OVERTEMPE(11, 0, "充电模块过温"),
    CHARGE_MODULE_COMMU_FAULT(11, 1, "充电模块通信故障"),
    CHARGE_MODULE_FAN_FAIL(11, 2, "充电模块风扇故障"),
    ENTRANCE_GUARD_FAULT(11, 3, "门禁故障"),
    DC_OUTPUT_CONTACTOR_ADHESION(11, 4, "直流输出接触器粘连"),
    ISOLATION_LISTEN_WARNING(11, 5, "绝缘监测告警"),
    DISCHARGE_CIRCUIT_FAULT(11, 6, "泄放回路故障"),
    CHARGING_PILE_OVERTEMPE_WARNING(11, 7, "充电桩过温告警"),
    PILE_OVERTEMPE_WARNING(12, 0, "充电枪过温告警"),
    AC_INPUT_CONTACTOR_FALSEACT_FAULT(12, 1, "交流输入接触器拒动/误动故障"),
    AC_OUTPUT_CONTACTOR_ADHESION(12, 2, "交流输入接触器粘连"),
    SUPPORT_POWER_FAULT(12, 3, "辅源故障"),
    MULTI_CONTRACTOR_FAULT(12, 4, "并联接触器故障"),
    MULTI_CONTRACTOR_ADHESION(12, 5, "并联接触器粘连"),
    HEARTBEAT_TIMEOUT(12, 6, "心跳超时"),
    V127(12, 7, "预留"),
    // -------------------------------以下为监控上层故障------------------------
    V120(13, 0, "预留"),
    V121(13, 1, "预留"),
    V122(13, 2, "预留"),
    V123(13, 3, "预留"),
    DIWEN_COMMU_WARNING(13, 4, "迪文通信告警"),
    AMMETER_COMMU_WARNING(13, 5, "电表通信告警"),
    CARDREADER_COMMU_WARNING(13, 6, "读卡器通信告警"),
    BUS_ERROR(13, 7, "总线错误"),
    BMS_BUS_ERROR(14, 0, "BMS 总线错误"),
    GROUP_COMMU_ERROR_HALT(14, 1, "群充+并充通讯错误，停机"),
    SLAVE_FAULT_HALT(14, 2, "从机故障导致 停机"),
    UPLOAD_CHARGE_RECORD_EXCEPTION(14, 3, "上传充电记录异常"),
    RATE_PARAM_EXCEPTION(14, 4, "费率参数异常"),
    ILLEGAL_REG_SYSTEM_EXCEPTION(14, 5, "注册信息无效，系统异常 暂停服务"),
    VER_CHECK_OVERTIME(14, 6, "版本校验超时"),
    SET_PARAM_NORESP(14, 7, "设置参数无回应"),
    RECEIVE_HEARTBEAT_OVERTIME(15, 0, "接收心跳报文超时"),
    TIME_SYNC_OVERTIME(15, 1, "时间同步超时"),
    DATA_SYNC_OVERTIME(15, 2, "数据同步超时"),
    PROTOCOL_VER_NOTSAME(15, 3, "协议版本不一致"),
    AMMETER_CULC_EXCEPTION(15, 4, "电表计量异常"),
    SETTING_NOTSAME(15, 5, "配置不一致"),
    SYNCDATA_LEN_NOTSAME(15, 6, "同步数据长度不一致"),
    CAN_SEND_EXCEPTION(15, 7, "CAN口发送异常"),
    CAN_SEND_FAULT(16, 0, "CAN口发送故障"),
    DAY1_GETTIME_FAIL(16, 1, "1号获取日期时间失败"),
    INIT_READSETTING_OVERTIME(16, 2, "初始化读取配置超时"),
    INIT_WRITESETTING_OVERTIME(16, 3, "初始化写入配置超时"),
    INIT_SYNCSETTING_FAIL(16, 4, "初始化同步配置失败"),
    AMMETER2_COMMU_WARNING(16, 5, "电表2通信告警"),
    POWERDATA_UPDATE_EXCEPTION(16, 6, "电能数据更新异常"),
    AMMETER_GETDATA_EXCEPTION(16, 7, "电表采集数据异常"),
    V170(17, 0, "预留"),
    V171(17, 1, "预留"),
    V172(17, 2, "预留"),
    V173(17, 3, "预留"),
    V174(17, 4, "预留"),
    V175(17, 5, "预留"),
    V176(17, 6, "预留"),
    V177(17, 7, "预留"),
    // -------------------------------以下为分体机层面故障------------------------
    INPUT_OVERVOL_FAULT(18, 0, "输入过压故障"),
    INPUT_LOWVOL_FAULT(18, 1, "输入欠压故障"),
    INPUT_OVERVOL_WARNING(18, 2, "输入过压告警"),
    INPUT_LOWVOL_WARNING(18, 3, "输入欠压告警"),
    INPUT_OVERFRE(18, 4, "输入过频"),
    INPUT_UNDERFRE(18, 5, "输入欠频"),
    AC_CONTRACTOR_FAULT(18, 6, "交流接触器故障"),
    SUPPORT_POWER_FAULL(18, 7, "辅助电源掉电"),
    LIGHTING_PROTECTER_FAULT(19, 0, "防雷器故障"),
    JERK(19, 1, "急停"),
    ENTRANCE_GUARD_WARNING(19, 2, "门禁告警"),
    AIR_INTAKE_OVERTEMPE(19, 3, "进风口过温"),
    AIR_INTAKE_LOWTEMPE(19, 4, "进风口低温"),
    AIR_OUTLET_OVERTEMPE(19, 5, "出风口过温"),
    PART_GROUP_CHARGE_OVERTEMPE(19, 6, "群充模块过温"),
    PART_GROUP_CHARGE_COMMU_FAULAT(19, 7, "群充模块通信故障"),
    AMMETER_COMMU_FAULT(19, 0, "电表通信故障"),
    PART_CHARGE_MODULE_COMMU_FAULT(19, 1, "充电模块通信故障"),







    UNKNOWN(99, 99, "未知");

    public static SystemWarningEnum getByPos(int bytePos, int bitPos) {
        for (SystemWarningEnum enums : SystemWarningEnum.values()) {
            if (Objects.equals(enums.bytePos, bytePos) && Objects.equals(enums.bitPos, bitPos) ) {
                return enums;
            }
        }
        return SystemWarningEnum.UNKNOWN;
    }



    SystemWarningEnum(int bytePos, int bitPos, String descr) {
        this.bytePos = bytePos;
        this.bitPos = bitPos;
        this.descr = descr;
    }

    public int bytePos;
    public int bitPos;
    public String descr;
}
